﻿// Copyright (c)  MOKEYISH. All rights reserved.
// Licensed under the MIT License, See License.txt in the project root for license information.

using System.Collections.Generic;

namespace NSQL.Expressions
{
    public class MatchExpression : BaseExpression, IMatchExpression
    {
        public IList<MatchPair<ILogicalExpression, IValueExpression>> Matches { get; } =
            new List<MatchPair<ILogicalExpression, IValueExpression>>();

        public IValueExpression Default { get; set; }

        public MatchExpression(IEnumerable<MatchPair<ILogicalExpression, IValueExpression>> matches,
            IValueExpression defaultValue)
        {
            foreach (var match in matches)
            {
                Matches.Add(match);
            }

            Default = defaultValue;
        }


        public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.Visit(this);
    }
}